<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="yanzheng">
    <input type="button" id="btn" value="验证">
    <input type="text" id="num" disabled>
    <script>
        var a = document.getElementById('yanzheng') ;
        var b = document.getElementById('btn')
        var c = document.getElementById('num')
        function randomNum(n, m) {
            var max, min;
            max = n > m ? n : m;
            min = n < m ? n : m;
            return parseInt(Math.random() * (max - min + 1) + min);
        }
        num.value=randomNum(1000, 9999)
        btn.onclick=function(){
            if(a.value*1 === num.value*1){
            alert('恭喜你，验证成功')
        }else{
            alert('恭喜你，验证失败')
        }
        }
       



    </script>
</body>
</html>